package java12;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class GBK201521123094 {

	public static void main(String[] args) throws Exception {
		convertGBK2UTF8("EncodeTest.txt", "NewEncodeTest.txt");
		Scanner in = null;
		String line = null;
		in = new Scanner(new File("NewEncodeTest.txt"));
		while (in.hasNextLine()) {
			line = in.nextLine();
			System.out.println(line);
		}
		in.close();

	}

	public static void convertGBK2UTF8(String src, String dst) throws Exception {
		BufferedReader br = null;
		try {
			FileInputStream fis = new FileInputStream(src);
			InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
			br = new BufferedReader(isr);
			String line = null;
			PrintWriter pw = null;
			pw = new PrintWriter(dst);
			while ((line = br.readLine()) != null)
				pw.write(line + "\n");
			pw.close();
		} finally {
			if (br != null) {
				br.close();
			}
		}
	}
}
